<%@ page import="java.util.List" %>
<%@ page import="com.example.exp_4_javaweb.Student" %>
<%@ page import="com.example.exp_4_javaweb.StudentHelper" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="student" class="com.example.exp_4_javaweb.Student"/>
<%
    List<Student> students = null;
    StudentHelper studentHelper = new StudentHelper();
    students = studentHelper.list();
%>
<%

%>
<div>
    <form action="addStudent" method="post">
        姓名：<input type="text" name="name"><br>
        密码：<input type="text" name="password"><br>
        <input type="submit" value="添加">
    </form>
</div>

<div id="list">
    <table>
        <tr>
            <td>num</td>
            <td>name</td>
            <td>password</td>
            <td>操作</td>
        </tr>
        <% for (int i=0;i<students.size();i++) { %>
        <tr>
            <td><%=students.get(i).getId()%></td>
            <td><%=students.get(i).getName()%></td>
            <td><%=students.get(i).getPassword()%></td>
            <td><a href="updateStudent.jsp?id=<%=students.get(i).getId()%>&name=<%=students.get(i).getName()%>&password=<%=students.get(i).getPassword()%>">修改</a></td>
            <td><a href="deleteStudent?id=<%=students.get(i).getId()%>">删除</a></td>
        </tr>
        <%}%>
    </table>

</div>
